package com.daidai.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.daidai.model.AssociationMember;
import com.daidai.model.AssociationMemberDTO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * Author: Mr.Chen
 * Date: 2022/08/01 9:27
 * Description:
 */
@Mapper
public interface AssociationMemberDao extends BaseMapper<AssociationMember> {

    @Select("select * from associationmember a,(select name,associationid from association) b where a.associationid=b.associationid and userid=#{userId}")
    AssociationMemberDTO findMemberById(@Param("userId") int userId);

    @Select("select * from associationmember a,(select name,associationid from association) b where a.associationid=b.associationid")
    List<AssociationMemberDTO> findAllMember();

    @Select("select * from associationmember a,(select name,associationid from association) b where a.associationid=b.associationid and userid=#{userId}")
    List<AssociationMemberDTO> findMemberByUserId(@Param("userId")int userId);
}
